//
//  PaperCardViewManager.m
//  ZYOnlineSchool
//
//  Created by 毕武侠 on 2017/2/27.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "PaperCardViewManager.h"


#import "PaperModuleModel.h"


@interface PaperCardViewManager ()


@property (nonatomic, strong, readwrite) RACSignal *cardSelectSignal;       // 选择Signal
@property (nonatomic, strong, readwrite) RACSignal *sendSignal;      // 提交Signal

@property (nonatomic, strong) NSMutableArray *cardDatas;

@end

@implementation PaperCardViewManager
@dynamic view;

- (void)setupConfigure {
    self.view = [[PaperCardView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.view.didHidden = YES;
    if (self.superView) {
        [self.superView addSubview:self.view];
    }
    self.view.alpha = 0.0f;
    
    [self.view setSourceDatas:self.datas];
    self.cardSelectSignal = [self.view getSignalWithDictionary:@{@"action" : @"select"}];
//    self.sendSignal   = [self.view getSignalWithDictionary:@{@"action" : @"send"}];
    
    PaperModuleModel * model = self.datas.firstObject;
    self.view.surplus = model.paper_time*60;
}

- (void)setShowToolTimer:(BOOL)showToolTimer {
    _showToolTimer = showToolTimer;
    self.view.showTimerView = self.showToolTimer;
}

- (void)setShowSendView:(BOOL)showSendView {
    _showSendView = showSendView;
    self.view.showSendView = showSendView;
}

- (void)setShowTitleView:(BOOL)showTitleView {
    _showTitleView = showTitleView;
    self.view.showTitleView = showTitleView;
}

- (void)setCardSignal:(RACSignal *)cardSignal {
    _cardSignal = cardSignal;
    
    @weakify(self)
    [_cardSignal subscribeNext:^(id x) {
        @strongify(self)
        [self.view showWithAnimation:YES withTime:[x integerValue]];
    }];
}
- (void)closeTimer{
    [self.view endTimer];
}
- (void)timeroutSendPaper{
    [self.view showWithAnimation:NO withTime:self.view.surplus];
}
@end
